package com.ryskoo.catering.employeetablerel.repository;

import com.ryskoo.catering.constant.HCLCacheConstant;
import com.ryskoo.catering.employeetablerel.domain.EmployeeTableRelPO;
import com.ryskoo.framework.core.repository.BasicRedisImpl;
import com.ryskoo.framework.core.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import java.util.List;

@Repository
@Primary
public class EmployeeTableRelRedisImpl extends BasicRedisImpl<EmployeeTableRelPO> implements IEmployeeTableRelRepository{

    @Autowired
    private RedisUtil redisClient;

    @Autowired
    private IEmployeeTableRelRepository employeeTableRelRepository;

    @PostConstruct
    public void init() {
        this.setRedisClient(redisClient);
        this.setDao(employeeTableRelRepository);
    }

    public EmployeeTableRelRedisImpl(){super(HCLCacheConstant.HCL_EMPLOYEE_DINNERTABLE_KEY);}

    @Override
    public EmployeeTableRelPO getByEmployeeAndTable(String employeeUuid, String tableUuid) {
        return employeeTableRelRepository.getByEmployeeAndTable(employeeUuid,tableUuid);
    }

    /**
     * 根据台桌uuid查询关联的服务员uuid集合
     *
     * @param tableUuid
     * @return
     */
    @Override
    public List<String> getEmpUuids(String tableUuid) {
        return employeeTableRelRepository.getEmpUuids(tableUuid);
    }
}
